import java.util.Scanner;

public class SingleSinglyLinkedList {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        Elem front = null;  
        Elem back  = null;   
        

        while (in.hasNext()) {
            String word = in.next();
            
            Elem e = new Elem();
            e.data = word;          

            
            if (front == null) {
                front = e;           
            } else {
                back.next = e; 
            }
            back = e;               
        }
        

        System.out.println("*** Print words in order of entry");
        Elem curr = front;
        while (curr != null) {
            System.out.println(curr.data);
            curr = curr.next;
        }
        
        System.out.println("*** Print words in order of entry");
        for (Elem e = front; e != null; e = e.next) {
            System.out.println(e.data);
        }
        

    }
}


class Elem {
    public Elem next;
    public String data;
}